/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * CadastroDistribuidores.java
 *
 * Created on 18/10/2011, 13:49:26
 */
package frames.Cadastro;

import classes.Distribuidor;
import frames.Gerenciamento.*;
import frames.Menus.*;

import java.awt.Color;
import javax.swing.JOptionPane;
import logicaBancoDeDados.ConectaDistribuidor;

public class CadastroDistribuidores extends javax.swing.JFrame {

    public Distribuidor distribuidor = new Distribuidor();

    public CadastroDistribuidores() {
        initComponents();
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel3 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jTextField5 = new javax.swing.JTextField();
        jButton4 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        tfEmpresa = new javax.swing.JTextField();
        tfEndereco = new javax.swing.JTextField();
        tfTelefone = new javax.swing.JTextField();
        lbMessage = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        btVoltar = new javax.swing.JButton();
        btCadastrar = new javax.swing.JButton();
        btLimpar = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuArquivo = new javax.swing.JMenu();
        itemMenuPrincipal = new javax.swing.JMenuItem();
        itemMenuCadastro = new javax.swing.JMenuItem();
        itemMenuGerenciamento = new javax.swing.JMenuItem();
        itemFechar = new javax.swing.JMenuItem();
        menuCadastro = new javax.swing.JMenu();
        itemCadastraDistribuidores = new javax.swing.JMenuItem();
        itemCadastraVendedores = new javax.swing.JMenuItem();
        itemCadastraProdutos = new javax.swing.JMenuItem();
        itemCadastraSaidaEstoque = new javax.swing.JMenuItem();
        menuGerenciamento = new javax.swing.JMenu();
        itemGerenciaCategorias = new javax.swing.JMenuItem();
        itemGerenciaDistribuidores = new javax.swing.JMenuItem();
        itemGerenciaGarantias = new javax.swing.JMenuItem();
        itemGerenciaProdutos = new javax.swing.JMenuItem();
        itemGerenciaVendedores = new javax.swing.JMenuItem();
        menuAjuda = new javax.swing.JMenu();
        itemSobre = new javax.swing.JMenuItem();

        jLabel3.setText("jLabel3");

        jLabel5.setText("jLabel5");

        jTextField5.setText("jTextField5");

        jButton4.setText("jButton4");

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Cadastra Distribuidor");

        jLabel1.setText("Empresa:");

        jLabel2.setText("Endereço:");

        jLabel6.setText("Telefone:");

        tfEmpresa.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                corEmpresa(evt);
            }
        });

        tfEndereco.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                corEndereco(evt);
            }
        });

        tfTelefone.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                corTelefone(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lbMessage, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 347, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tfTelefone)
                            .addComponent(tfEmpresa)
                            .addComponent(tfEndereco, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(tfEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(tfEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tfTelefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lbMessage, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(13, Short.MAX_VALUE))
        );

        btVoltar.setText("Voltar");
        btVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btVoltarActionPerformed(evt);
            }
        });

        btCadastrar.setText("Cadastrar");
        btCadastrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCadastrarActionPerformed(evt);
            }
        });

        btLimpar.setText("Limpar");
        btLimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLimparActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btCadastrar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btLimpar)
                .addGap(6, 6, 6)
                .addComponent(btVoltar)
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btCadastrar, btLimpar, btVoltar});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btVoltar)
                    .addComponent(btCadastrar)
                    .addComponent(btLimpar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        menuArquivo.setText("Menu");

        itemMenuPrincipal.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.SHIFT_MASK));
        itemMenuPrincipal.setText("Menu Principal");
        itemMenuPrincipal.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemMenuPrincipalActionPerformed(evt);
            }
        });
        menuArquivo.add(itemMenuPrincipal);

        itemMenuCadastro.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.SHIFT_MASK));
        itemMenuCadastro.setText("Menu Cadastro");
        itemMenuCadastro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemMenuCadastroActionPerformed(evt);
            }
        });
        menuArquivo.add(itemMenuCadastro);

        itemMenuGerenciamento.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.CTRL_MASK));
        itemMenuGerenciamento.setText("Menu Gerenciamento");
        itemMenuGerenciamento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemMenuGerenciamentoActionPerformed(evt);
            }
        });
        menuArquivo.add(itemMenuGerenciamento);

        itemFechar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        itemFechar.setText("Fechar");
        itemFechar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemFecharActionPerformed(evt);
            }
        });
        menuArquivo.add(itemFechar);

        jMenuBar1.add(menuArquivo);

        menuCadastro.setText("Cadastro");

        itemCadastraDistribuidores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.CTRL_MASK));
        itemCadastraDistribuidores.setText("Distribuidores");
        itemCadastraDistribuidores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemCadastraDistribuidoresActionPerformed(evt);
            }
        });
        menuCadastro.add(itemCadastraDistribuidores);

        itemCadastraVendedores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_SPACE, java.awt.event.InputEvent.CTRL_MASK));
        itemCadastraVendedores.setText("Vendedores");
        itemCadastraVendedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemCadastraVendedoresActionPerformed(evt);
            }
        });
        menuCadastro.add(itemCadastraVendedores);

        itemCadastraProdutos.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER, 0));
        itemCadastraProdutos.setText("Produtos");
        itemCadastraProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemCadastraProdutosActionPerformed(evt);
            }
        });
        menuCadastro.add(itemCadastraProdutos);

        itemCadastraSaidaEstoque.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        itemCadastraSaidaEstoque.setText("Saida de Estoque");
        itemCadastraSaidaEstoque.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemCadastraSaidaEstoqueActionPerformed(evt);
            }
        });
        menuCadastro.add(itemCadastraSaidaEstoque);

        jMenuBar1.add(menuCadastro);

        menuGerenciamento.setText("Gerenciamento");

        itemGerenciaCategorias.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaCategorias.setText("Categorias");
        itemGerenciaCategorias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaCategoriasActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaCategorias);

        itemGerenciaDistribuidores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaDistribuidores.setText("Distribuidores");
        itemGerenciaDistribuidores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaDistribuidoresActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaDistribuidores);

        itemGerenciaGarantias.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaGarantias.setText("Garantias");
        itemGerenciaGarantias.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaGarantiasActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaGarantias);

        itemGerenciaProdutos.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaProdutos.setText("Produtos");
        itemGerenciaProdutos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaProdutosActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaProdutos);

        itemGerenciaVendedores.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        itemGerenciaVendedores.setText("Vendedores");
        itemGerenciaVendedores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemGerenciaVendedoresActionPerformed(evt);
            }
        });
        menuGerenciamento.add(itemGerenciaVendedores);

        jMenuBar1.add(menuGerenciamento);

        menuAjuda.setText("Ajuda");

        itemSobre.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F12, 0));
        itemSobre.setText("Sobre");
        itemSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                itemSobreActionPerformed(evt);
            }
        });
        menuAjuda.add(itemSobre);

        jMenuBar1.add(menuAjuda);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(102, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

   private void itemMenuPrincipalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemMenuPrincipalActionPerformed
       new MenuPrincipal().setVisible(true);
       dispose();
    }//GEN-LAST:event_itemMenuPrincipalActionPerformed
    
    private void itemMenuCadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemMenuCadastroActionPerformed
        new MenuCadastro().setVisible(true);
    }//GEN-LAST:event_itemMenuCadastroActionPerformed
    
    private void itemMenuGerenciamentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemMenuGerenciamentoActionPerformed
        new MenuGerenciamento().setVisible(true);
    }//GEN-LAST:event_itemMenuGerenciamentoActionPerformed
    
    private void itemFecharActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemFecharActionPerformed
        int resposta = JOptionPane.showConfirmDialog(null, "Deseja realmente encerrar o programa", "Confirmação", JOptionPane.YES_NO_OPTION);
        if (resposta == 0) {
            System.exit(0);
            dispose();
        }
    }//GEN-LAST:event_itemFecharActionPerformed
    
    private void itemCadastraDistribuidoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCadastraDistribuidoresActionPerformed
        new CadastroDistribuidores().setVisible(true);
    }//GEN-LAST:event_itemCadastraDistribuidoresActionPerformed
    
    private void itemCadastraVendedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCadastraVendedoresActionPerformed
        new CadastroVendedores().setVisible(true);
    }//GEN-LAST:event_itemCadastraVendedoresActionPerformed
    
    private void itemCadastraProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCadastraProdutosActionPerformed
        new CadastroProdutos().setVisible(true);
    }//GEN-LAST:event_itemCadastraProdutosActionPerformed
    
    private void itemCadastraSaidaEstoqueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemCadastraSaidaEstoqueActionPerformed
        new CadastroSaidasEstoque().setVisible(true);
    }//GEN-LAST:event_itemCadastraSaidaEstoqueActionPerformed
    
    private void itemGerenciaCategoriasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaCategoriasActionPerformed
        new GerenciaCategorias().setVisible(true);
    }//GEN-LAST:event_itemGerenciaCategoriasActionPerformed
    
    private void itemGerenciaDistribuidoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaDistribuidoresActionPerformed
        new GerenciaDistribuidores().setVisible(true);
        
    }//GEN-LAST:event_itemGerenciaDistribuidoresActionPerformed
    
    private void itemGerenciaGarantiasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaGarantiasActionPerformed
        new GerenciaGarantias().setVisible(true);
        
    }//GEN-LAST:event_itemGerenciaGarantiasActionPerformed
    
    private void itemGerenciaProdutosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaProdutosActionPerformed
        new GerenciaProdutos().setVisible(true);
    }//GEN-LAST:event_itemGerenciaProdutosActionPerformed
    
    private void itemGerenciaVendedoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemGerenciaVendedoresActionPerformed
        new GerenciaVendedores().setVisible(true);
    }//GEN-LAST:event_itemGerenciaVendedoresActionPerformed
    
    private void itemSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_itemSobreActionPerformed
        JOptionPane.showMessageDialog(null, "Programa criado por Danilo Vicente Diorio \n\n\n Sob Licença GPL.");
    }//GEN-LAST:event_itemSobreActionPerformed
    
    private void btCadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCadastrarActionPerformed
       if(confirmaCampos() == true){
           distribuidor.setDistribuidor(tfEmpresa.getText());
           distribuidor.setEndereco(tfEndereco.getText());
           distribuidor.setTelefone(tfTelefone.getText());
       }
    }//GEN-LAST:event_btCadastrarActionPerformed
    
    private void btLimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLimparActionPerformed
        limparTudo();
    }//GEN-LAST:event_btLimparActionPerformed
    
    private void btVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btVoltarActionPerformed
        int i = JOptionPane.showConfirmDialog(null, "Confirma", "Deseja realmente voltar", JOptionPane.OK_OPTION);
        if (i == 0) {
            new MenuPrincipal().setVisible(true);
            dispose();
        }
    }//GEN-LAST:event_btVoltarActionPerformed
    
    private void corEmpresa(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_corEmpresa
        tfEmpresa.setBackground(Color.WHITE);
        lbMessage.setText(null);
    }//GEN-LAST:event_corEmpresa
    
    private void corEndereco(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_corEndereco
        tfEndereco.setBackground(Color.WHITE);
        lbMessage.setText(null);
    }//GEN-LAST:event_corEndereco

    private void corTelefone(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_corTelefone
        tfTelefone.setBackground(Color.WHITE);
        lbMessage.setText(null);
    }//GEN-LAST:event_corTelefone

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadastroDistribuidores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadastroDistribuidores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadastroDistribuidores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadastroDistribuidores.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            
            public void run() {
                new CadastroDistribuidores().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCadastrar;
    private javax.swing.JButton btLimpar;
    private javax.swing.JButton btVoltar;
    private javax.swing.JMenuItem itemCadastraDistribuidores;
    private javax.swing.JMenuItem itemCadastraProdutos;
    private javax.swing.JMenuItem itemCadastraSaidaEstoque;
    private javax.swing.JMenuItem itemCadastraVendedores;
    private javax.swing.JMenuItem itemFechar;
    private javax.swing.JMenuItem itemGerenciaCategorias;
    private javax.swing.JMenuItem itemGerenciaDistribuidores;
    private javax.swing.JMenuItem itemGerenciaGarantias;
    private javax.swing.JMenuItem itemGerenciaProdutos;
    private javax.swing.JMenuItem itemGerenciaVendedores;
    private javax.swing.JMenuItem itemMenuCadastro;
    private javax.swing.JMenuItem itemMenuGerenciamento;
    private javax.swing.JMenuItem itemMenuPrincipal;
    private javax.swing.JMenuItem itemSobre;
    private javax.swing.JButton jButton4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JLabel lbMessage;
    private javax.swing.JMenu menuAjuda;
    private javax.swing.JMenu menuArquivo;
    private javax.swing.JMenu menuCadastro;
    private javax.swing.JMenu menuGerenciamento;
    private javax.swing.JTextField tfEmpresa;
    private javax.swing.JTextField tfEndereco;
    private javax.swing.JTextField tfTelefone;
    // End of variables declaration//GEN-END:variables

    private boolean confirmaCampos() {
        String erro = "";
        boolean cond = true;
        if (tfEmpresa.getText().isEmpty() || tfEndereco.getText().isEmpty() || tfTelefone.getText().isEmpty()) {
            if (tfEmpresa.getText().isEmpty()) {
                tfEmpresa.setBackground(Color.red);
            }
            if (tfEndereco.getText().isEmpty()) {
                tfEndereco.setBackground(Color.red);
            }
            if (tfTelefone.getText().isEmpty()) {
                tfTelefone.setBackground(Color.red);
                erro+="Favor preencher os campos em vermelho";
            }
            cond = false;
        } else {
            if(tfTelefone.getText().matches("^[0-9 ()-/]*$") == false || tfTelefone.getText().length() < 8){
                tfTelefone.setBackground(Color.red);
                erro+= "Telefone informado errado";
                cond = false;
            }
        }
         lbMessage.setText(erro);
         return cond;
    }

    private void limparTudo() {
        tfEmpresa.setText(null);
        tfEndereco.setText(null);
        tfTelefone.setText(null);
        tfEmpresa.setBackground(Color.WHITE);
        tfEndereco.setBackground(Color.WHITE);
        tfTelefone.setBackground(Color.WHITE);
        lbMessage.setText(null);
    }
}
